<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>历史检测结果</title>
  <link rel="shortcut icon" href="__PUBLIC__/favicon.ico">
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="__PUBLIC__/style/template.css" media="all">
</head>
<body>
  <div style="margin:30px;">
    <table id="scanlog_tb" lay-filter="scanlog_tb"></table>
  </div>

  <script type="text/html" id="nameTpl">
    <a href="#" class="layui-table-link" onclick="scan_detail('{{d.id}}','{{d.target}}')">{{d.target}}</a>
  </script>
  
  <script src="__PUBLIC__/layui/layui.js"></script>  
  <script>
    layui.use(['table'], function(){
        var table = layui.table
        ,$ = layui.$;

        var tableIns = table.render({
          elem: '#scanlog_tb'
          ,limit: 20
          ,url: '/Home/Ajax/ajax_scan_log'
          ,page: true
          ,cols: [[
            {field: 'id', title: 'ID', width:80}
            ,{field: 'target', title: '目标', templet: '#nameTpl'}
            ,{field: 'progress', title: '进度', width:150}
            ,{field: 'time', title: '时间', width:200, templet:
              function(d){
                return UnixTimeFormat(d.time);
              }}
          ]]
        });
        
        
        function UnixTimeFormat(t){
          var unixTimestamp = new Date(t*1000);
          var commonTime = unixTimestamp.toLocaleString();
          return commonTime;
        }
    });

    function scan_detail(id,target){
      event.preventDefault(); // 阻止默认行为
      layer.open({
        type: 2,
        area: ['80%', '90%'],
        fixed: false,
        maxmin: true,
        title: target,
        content: '/Home/Index/scan_detail?id='+id
      });
    }
  </script>
</body>
</html>
